import dearpygui.dearpygui as dpg


def  draw1():
    dpg.create_context()

    width, height, channels, data = dpg.load_image(
        "image/car2.jpg"
    )  # 0: width, 1: height, 2: channels, 3: data

    with dpg.texture_registry():
        dpg.add_static_texture(width, height, data, tag="image_id")

    with dpg.window(label="Tutorial"):
        with dpg.drawlist(width=700, height=700):
            dpg.draw_image("image_id", (0, 400), (200, 600), uv_min=(0, 0), uv_max=(1, 1))

    dpg.create_viewport(title="Custom Title", width=800, height=600)
    dpg.setup_dearpygui()
    dpg.show_viewport()
    dpg.start_dearpygui()


def draw2():
    dpg.create_context()



    width, height, channels, data = dpg.load_image("image/car1.jpg")

    with dpg.texture_registry(show=True):
        dpg.add_static_texture(
            width=width, height=height, default_value=data, tag="texture_tag"
        )

    with dpg.window(label="Tutorial"):
        dpg.add_image("texture_tag")

    dpg.create_viewport(title="车牌识别", width=1200, height=900)
    dpg.setup_dearpygui()
    dpg.show_viewport()
    dpg.start_dearpygui()
    dpg.destroy_context()


def save():
    import dearpygui.dearpygui as dpg

    dpg.create_context()
    dpg.create_viewport()
    dpg.setup_dearpygui()

    width, height = 255, 255

    data = []
    for i in range(width * height):
        data.append(255)
        data.append(255)
        data.append(0)

    with dpg.window(label="Tutorial"):
        dpg.add_button(
            label="Save Image",
            callback=lambda: dpg.save_image(
                file="newImage.png", width=width, height=height, data=data, components=3
            ),
        )

    dpg.show_viewport()
    while dpg.is_dearpygui_running():
        dpg.render_dearpygui_frame()

    dpg.destroy_context()

import os

cwd = os.getcwd()
recognize_result_path = os.path.join("result", "bucket")
recognize_result_path =  cwd+"\\"+recognize_result_path
print(recognize_result_path)
